/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pw.yitree.game;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;

/**
 *
 * @author Administrator
 */
@Converter
public class GameConverter implements AttributeConverter<Game, String> {

    @Override
    public String convertToDatabaseColumn(Game value) {
        if (value == null) {
            return null;
        }

        return value.getCode();
    }

    @Override
    public Game convertToEntityAttribute(String value) {
        if (value == null) {
            return null;
        }

        return Game.fromCode(value);
    }
}
